package com.simas.common;

//import net.rim.device.api.system.Bitmap;
import net.rim.device.api.system.Display;
//import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Field;
//import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.FontFamily;
import net.rim.device.api.ui.Graphics;
//import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.Ui;
//import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
//import net.rim.device.api.ui.container.FlowFieldManager;
import net.rim.device.api.ui.container.HorizontalFieldManager;

public class CustomResources {
//	private Bitmap bitLogo = Bitmap.getBitmapResource("Simas.png");
	
	// server blackberry rumah
	//private String strServer = "http://192.168.2.104:8083/SimasServer/";
	
	// server 202
	//private String strServer = "http://192.168.10.202:8086/SimasServer/";
	
	// server lokal
	private String strServer = "http://192.168.10.130:8083/SimasServer/";
	
	// server live, testing
	//private String strServer = "http://192.168.105.23:8083/SimasServer/";
	
	// server live, live
	//private String strServer = "http://203.142.85.213:8083/SimasServer/";
	
	//private String strHIDurl = strServer + "BBApp_cMainScreen?hidMode=1";
	//private String strMBUurl = strServer + "BBApp_cMobilScreen?hidMode=1";
	
	private String strHIDServlet = strServer + "BBApp_cMainScreen";
	private String strMBUServlet = strServer + "BBApp_cMobilScreen";
	private String strINFOServlet = strServer + "BBApp_cInfoScreen";
	
	//private String choices[] = {"- Pilih Jenis Polis -", "Simas Sehat", "Simas Mobil", "Simas Rumah", "Simas Travel", "Personal Accident"};
//	private String choices[] = {" ", "Simas Sehat", "Simas Mobil"};
//	private String info[] = {" ", "Daftar RS Provider", "Info Perusahaan", "Testimoni", "Info Asuransi"};
	private int intIdxHIDScreen = 1;
	private int intIdxMBUScreen = 2;
//	private int intIdxRUMAHScreen = 3;
//	private int intIdxTRAVELScreen = 4;
//	private int intIdxPERSONALScreen = 5;
	
//	private int intDebug = 0;
	
	public int getIntIdxHIDScreen() {
		return intIdxHIDScreen;
	}

	public int getIntIdxMBUScreen() {
		return intIdxMBUScreen;
	}
//
//	public String[] getDDLPolis() {
//		return choices;
//	}
//	
//	public String[] getDDLInformasi() {
//		return info;
//	}
	
	public Font getCustomFont() {
		Font appFont = null;
		try {
			FontFamily alphaSansFamily = FontFamily.forName("BBAlpha Sans");
			appFont = alphaSansFamily.getFont(Font.PLAIN, 5, Ui.UNITS_pt);
		}
		catch (ClassNotFoundException cnfe) {
			// nothing
		}
		return appFont;
	}
	
	public Font getCustomFont(int intSize) {
		Font appFont = null;
		try {
			FontFamily alphaSansFamily = FontFamily.forName("BBAlpha Sans");
			appFont = alphaSansFamily.getFont(Font.PLAIN, intSize, Ui.UNITS_pt);
		}
		catch (ClassNotFoundException cnfe) {
			// nothing
		}
		return appFont;
	}
	
	public Font getHeaderFont() {
		Font appFont = null;
		try {
			FontFamily alphaSansFamily = FontFamily.forName("BBAlpha Sans");
			appFont = alphaSansFamily.getFont(Font.PLAIN, 5, Ui.UNITS_pt);
		}
		catch (ClassNotFoundException cnfe) {
			appFont = getCustomFont();
		}
		return appFont;
	}
	
//	public LabelField myCustomLabel(String strText, int intFontSize, long lngStyle) {
//		LabelField lblField = null;
//		// Set Font Size
//		Font appFont = null;
//		try {
//			FontFamily alphaSansFamily = FontFamily.forName("BBAlpha Sans");
//			appFont = alphaSansFamily.getFont(Font.PLAIN, intFontSize, Ui.UNITS_pt);
//		}
//		catch (ClassNotFoundException cnfe) {
//			appFont = getCustomFont();
//		}
//		// Remake String
//		lblField = new LabelField(strText, Field.FIELD_LEFT | lngStyle);
//		lblField.setFont(appFont);
//		return lblField;
//	}
	
	public HorizontalFieldManager getHeaderRibbon(String strText, int intFontSize) {
		HorizontalFieldManager hfm = new HorizontalFieldManager(Field.USE_ALL_WIDTH | Field.FIELD_RIGHT){
			public void paint(Graphics graphics){
                graphics.setBackgroundColor(Integer.parseInt("CC9966", 16));
                graphics.clear();
                super.paint(graphics);
            }
        };
		LabelField headerField = new LabelField(" [ " + strText + " ] ", Field.FIELD_RIGHT){
			public void paint(Graphics graphics){
				graphics.setColor(Integer.parseInt("FFFFFF", 16));
				graphics.clear();
				super.paint(graphics);
            }
		};
		Font headerFont = null;
		if (intFontSize > 0) {
			try {
				FontFamily alphaSansFamily = FontFamily.forName("BBAlpha Sans");
				headerFont = alphaSansFamily.getFont(Font.PLAIN, intFontSize, Ui.UNITS_pt);
			}
			catch (ClassNotFoundException cnfe) {
				// nothing
			}
		} else {
			headerFont = getHeaderFont();
		}
	    headerField.setFont(headerFont);
	    hfm.add(headerField);
	    return hfm;
	}
	
//	public Bitmap getBitLogo() {
//		return bitLogo;
//	}
	
	public String getImageURL(String strFileName) {
		String strURL = "";
		int intWidth = Display.getWidth();
		if (intWidth < 480) {
			strURL = "320/" + strFileName;
		} else {
			strURL = "480/" + strFileName;
		}
		return strURL;
	}
	
//	public String getStrHIDurl() {
//		return strHIDurl;
//	}
	
//	public String getStrMBUurl() {
//		return strMBUurl;
//	}
	
	public String getStrHIDServlet() {
		return strHIDServlet;
	}
	
	public String getStrMBUServlet() {
		return strMBUServlet;
	}
	
	public String getStrINFOServlet() {
		return strINFOServlet;
	}

//	public void setIntDebug(int intDebug) {
//		this.intDebug = intDebug;
//	}

//	public int getIntDebug() {
//		return intDebug;
//	}
}
